export class StorageApi {
	/**
	 * authorization存入缓存
	 * @param {Object} value
	 */
	static setAuthorization(value) {
		return uni.setStorageSync('authorization', value)
	}
	
	/**
	 * 缓存中读取authorization
	 */
	static getAuthorization() {
		let authorization = uni.getStorageSync('authorization') || "";
		return authorization ? `Bearer ${authorization}` : "";
	}
	
	static setYouinAuthorization(value) {
		return uni.setStorageSync('YouinAuthorization', value)
	}
	
	/**
	 * 缓存中读取authorization
	 */
	static getYouinAuthorization() {
		let authorization = uni.getStorageSync('YouinAuthorization');
		return authorization ? `JWT ${authorization}` : "";
	}
	
	/**
	 * 用户信息存入缓存
	 * @param {Object} value
	 */
	static setUserInfo(value) {
		let info = JSON.stringify(value)
		return uni.setStorageSync('userInfo', info);
	}
	
	/**
	 * 缓存中读取用户信息
	 */
	static getUserInfo() {
		let info = uni.getStorageSync('userInfo')
			console.log('缓存中读取用户信息',info)
		return JSON.parse(info)
	}
	
	/**
	 * 企业信息存入缓存
	 * @param {Object} value
	 */
	static setQyInfo(value) {
		let info = JSON.stringify(value)
		return uni.setStorageSync('qyInfo', info);
	}
	
	/**
	 * 缓存中读取企业信息
	 */
	static getQyInfo() {
		let info = uni.getStorageSync('qyInfo')
		console.log('缓存中读取企业信息',info)
		return JSON.parse(info)
	}
	
	/**
	 * 缓存中读取env
	 */
	static getEnv() {
		return uni.getStorageSync('env') || 'prod';
	}
	
	/**
	 * env存入缓存中
	 */
	static setEnv(value) {
		return uni.setStorageSync('env', value);
	}
	
	/**
	 * 缓存清空
	 */
	static clear() {
		return uni.clearStorageSync();
	}
}
